#ifndef __PCRESOURCE_H_
#define _PCRESOURCE_H_

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
}
#endif

#include <string>
#include <string.h>
#include <thread>
#include <mutex>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include "PCResourceUI.h"

using namespace std;

class PCResource;

class PCResource
{

public:
    
private:
    thread *pThread;         //独立于UI的线程
    mutex *uiMutex;        //UI资源互斥锁
    bool threadExitFlag;          //线程退出标志
    int socketFd;          //socket描述符
    string ipAddr;         //服务器ip地址(点分十进制)
    int port;               // 端口号

    struct sockaddr_in serverAddr;     //服务器地址

    int updateTime;     // 更新间隔

    bool getConfig(void);
    int getData(string &info);
    PCResInfo analyticData(string &info);

    int threadFunction(void);

public:
    PCResource(function<void(void)> exitCb, mutex &UIMutex);
    ~PCResource();
};



#endif